<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Save Text to File</title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/FileSaver.js/2.0.5/FileSaver.min.js"></script>
</head>
<body>
    <textarea id="inputText" rows="10" cols="50" placeholder="Enter your text here..."></textarea><br>
    <button id="saveButton">Save to File</button>

    <script>
        document.getElementById('saveButton').addEventListener('click', function() {
            // 获取用户输入的内容
            const text = document.getElementById('inputText').value;

            // 创建一个 Blob 对象
            const blob = new Blob([text], { type: 'text/plain' });

            // 使用 FileSaver.js 保存文件
            saveAs(blob, 'output.txt');
        });
    </script>
</body>
</html>